import pymysql
import pandas as pd

conn = pymysql.connect(host='localhost', user='root', password='123456', db='test')

df = pd.read_excel('文件路径')
for index, row in df.iterrows():
    cursor = conn.cursor()
    sql = """
    insert into db_student(name, age) values ('{}')
    """
    cursor.execute(sql)
    conn.commit()
    
conn.close()